﻿namespace Home.Configuration
{
    using System;
    using System.Collections.Generic;
    using System.Globalization;
    using System.Linq;
    using System.Web;
    using System.Web.Configuration;

    public static class ConfigurationHelper
    {
        public static bool IsDevelopmentEnvironment
        {
            get { return WebConfigurationManager.AppSettings["home:Environment"] == "Development"; }
        }

        public static bool IsUnitTestEnvironment
        {
            get { return WebConfigurationManager.AppSettings["home:Environment"] == "UnitTest"; }
        }

        public static bool IsE2ETestEnvironment
        {
            get { return WebConfigurationManager.AppSettings["home:Environment"] == "E2ETest"; }
        }

        public static bool IsProductionEnvironment
        {
            get { return WebConfigurationManager.AppSettings["home:Environment"] == "Production"; }
        }

        public static string ProductVersion
        {
            get { return WebConfigurationManager.AppSettings["home:ProductVersion"]; }
        }

        public static string CssVersion
        {
            get { return WebConfigurationManager.AppSettings["home:CssVersion"]; }
        }

        public static string JavaScriptVersion
        {
            get { return WebConfigurationManager.AppSettings["home:JavaScriptVersion"]; }
        }

        public static TimeSpan SessionTimeoutInterval
        {
            get { return TimeSpan.FromMinutes(double.Parse(WebConfigurationManager.AppSettings["home:SessionTimeoutInterval"], NumberStyles.Number, CultureInfo.InvariantCulture)); }
        }

        public static string WebsiteAddress
        {
            get { return WebConfigurationManager.AppSettings["home:WebsiteAddress"]; }
        }

        public static string IdentityProviderAppKeyQQ
        {
            get { return WebConfigurationManager.AppSettings["home:IdentityProvider-AppId-QQ"]; }
        }

        public static string IdentityProviderSecretQQ
        {
            get { return WebConfigurationManager.AppSettings["home:IdentityProvider-Secret-QQ"]; }
        }

        public static string IdentityProviderAppKeySina
        {
            get { return WebConfigurationManager.AppSettings["home:IdentityProvider-AppId-Sina"]; }
        }

        public static string IdentityProviderSecretSina
        {
            get { return WebConfigurationManager.AppSettings["home:IdentityProvider-Secret-Sina"]; }
        }

        public static string IdentityProviderAppKeyWeChat
        {
            get { return WebConfigurationManager.AppSettings["home:IdentityProvider-AppId-WeChat"]; }
        }

        public static string IdentityProviderSecretWeChat
        {
            get { return WebConfigurationManager.AppSettings["home:IdentityProvider-Secret-WeChat"]; }
        }

        public static TimeSpan MaxLoginTime
        {
            get
            {
                var text = WebConfigurationManager.AppSettings["home:MaxLoginTimeSpanInMinute"];
                var number = int.Parse(text);
                var time = TimeSpan.FromMinutes(number);
                return time;
            }
        }
    }
}